﻿@{
    ViewBag.Title = "UserPwdUpd";
    Layout = "~/Views/Shared/MasterView.cshtml";
}
<link type="text/css" rel="stylesheet" href="/pc/themes/base.css">
<link type="text/css" rel="stylesheet" href="/pc/themes/ceng.css">
<link type="text/css" rel="stylesheet" href="/pc/themes/Safe.css">
<link rel="stylesheet" type="text/css" href="/pc/themes/util.css" />
<script>
    var Umodel = "";
    $(function () {
        $.post("/SecurityCenter/UserPwdTest", {}, function (mes) {
            if (mes != "")
            {
                Umodel = mes
                $("#NowName").html(Umodel.UserName)
            }
        })
    })
    function TestOldPwd()
    {
        if ($("#password").val()!="")
        {
            if (Umodel.UserPwd != $("#password").val()) {
                $("#Spwd").html("输入密码与原始密码不符合")
                $("#Spwd").css("color", "red")
                return false;
            }
            else
            {
                $("#Spwd").html("✔")
                $("#Spwd").css("color", "green")
            }
        }
        else
        {
            $("#Spwd").html("请输入原始密码")
            $("#Spwd").css("color", "red")
            return false;
        }
    }
    function NewPassword() {
        var reg = /^[a-zA-Z0-9]\w{6,18}$/;
        if ($("#NewPassword").val() != "")
        {

            if (!reg.test($("#NPassword").val()))
            {
                $("#Npwd").html("密码长度在6-16位，以数字和字母组合")
                $("#Npwd").css("color", "red")
                return false;
            }
            else
            {
                $("#Npwd").html("✔")
                $("#Npwd").css("color", "green")
            }
        }
        else
        {
            $("#Npwd").html("新密码不能为空")
            $("#Npwd").css("color", "red")
            return false;
        }
    }
    function NewPasswordTwo() {
        if ($("#NPasswordTwo").val() != "")
        {
            if ($("#NPassword").val() != $("#NPasswordTwo").val())
            {
                $("#NpwdT").html("两次密码不一致，请重新输入")
                $("#NpwdT").css("color", "red")
                return false;
            }
            else {
                $("#NpwdT").html("✔")
                $("#NpwdT").css("color", "green")
            }
        }
        else {
            $("#NpwdT").html("新密码不能为空")
            $("#NpwdT").css("color", "red")
            return false;
        }
    }
    function UpdUserPwd()
    {
        TestOldPwd();
        NewPassword();
        NewPasswordTwo();
        $.ajax({
            url: "/SecurityCenter/UserpPwdUpd",
            type: "post",
            data: {
                UserId: Umodel.UserId,
                NPwd: $("#NPassword").val()
            }
            , success: function (mes)
            {
                if (mes!=0)
                {
                    location.href = '/Myaccount/MyaccountSecurityCenter'
                }
                else
                {
                    alert("出错了")
                    location.reload();
                }
            }
        })
    }
</script>
<div class="content" id="hongman">
    <div class="Bind">
        <style type="text/css">
            .span_lf {
                margin: 20px 0 20px 150px;
            }

                .span_lf .but_jb {
                    margin-left: 5px;
                }
        </style>
        <div class="path_safe">
            <span><a href="/Myaccount/MyaccountSecurityCenter">安全中心</a></span><em>&gt;</em><span><a href="">密码管理</a></span><em>&gt;</em><span>修改登录密码</span>
        </div>
        <div class="clear">

        </div>
        <div style="" class="span_lf">
                <ul>
                    <li>
                        <span class="sp_1">当前用户名：</span><span style="height: 33px; line-height:33px;">
                            <strong class="red" id="NowName">
                                                  
                            </strong>
                        </span>
                    </li>
                    <li>
                        <span class="sp_1">原登录密码：</span><span>
                            <input type="password"  value="" maxlength="16"
                                    class="txt_180 font_ya" name="password" id="password" onblur="TestOldPwd()">
                        </span>
                        <span id="Spwd">

                        </span>
                    </li>
                    <li>
                        <span class="sp_1">新登录密码：</span><span>
                            <input type="password"  value="" maxlength="16" onblur="NewPassword()"
                                   class="txt_180 font_ya" name="newPassword" id="NPassword" >
                        </span>
                        <span id="Npwd">

                        </span>
                    </li>
                    <li>
                        <span class="sp_1">确认新登录密码：</span><span>
                            <input type="password"  value="" maxlength="16"  onblur="NewPasswordTwo()" class="txt_180 font_ya" 
                                   name="confirmNewPassword" id="NPasswordTwo">
                        </span>
                        <span id="NpwdT">

                        </span>
                    </li>
                </ul>
                <div class="clear">
                </div>
                <p style="margin: 10px 0 0 150px;" class="span_lf_but">
                    <input type="button" value="确 定" id="formsubmitbutton" class="Flat_but"><a href="//" class="">忘了密码？？</a>
                </p>
        </div>
    </div>
</div>


